package YiranJklgj01;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectExp02 {
    public static void main(String[] args) {
        try {
            Class studentClass = Class.forName("YiranJklgj01.Student");
            Constructor con = studentClass.getConstructor(int.class,String.class,int.class,String.class);
            Object obj = con.newInstance(2021020304,"取悦",22,"湖南长沙");
            Method sayHelloMethod = studentClass.getMethod("sayHello");
            sayHelloMethod.invoke(obj);
        } catch (ClassNotFoundException | NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

    }
}
